define(['jquery','cookie'],function($){
	var soKey='SOSESSID',
	    nickname=$.cookie('nickname'),
	    headimgurl=$.cookie('headimgurl'),
	    isRegister;
	return {
		checkLogin:function(){
			if($.cookie(soKey)){
				return true;
			}else{
			    window.location.hash="#/login";
			    return false;
			}
		},
		isLogin:function(){
			return !!$.cookie(soKey);
		},
		loginOut:function(){
			if(!$.cookie(soKey))return;
			$.removeCookie(soKey);
			location.hash=location.hash=='#/'||location.hash==''?'#/login':'#/';
		},
		setIsRegister:function(b){
			isRegister=b;
		},
		isRegister:function(){
			return isRegister=='1';
		},
		key:function(){
			return soKey;
		},
		data:{
			username:nickname?nickname:'--',
			mobile:$.cookie('mobile'),
			headimgurl:headimgurl?headimgurl:'/static/img/avatar.jpg'
		}
	}
})